Everyone knows FIGlet or at least have seen once or twice the output of FIGlet even whether they know what generates those or not. But not everyone knows that there is a port of FIGlet, I was one of them until I came across a program called termdown, which is a countdown timer and depends on the port of FIGlet, pyfiglet:
_|_| _| _| _|
_|_|_| _| _| _| _|_|_| _| _|_| _|_|_|_|
_| _| _| _| _|_|_|_| _| _| _| _| _|_|_|_| _|
_| _| _| _| _| _| _| _| _| _| _|
_|_|_| _|_|_| _| _| _|_|_| _| _|_|_| _|_|
_| _| _|
_| _|_| _|_|
Lets compare the CLIs, FIGlet v2.2.2 (2005-08-05) and pyfiglet v0.7 (2014-06-08):
$ figlet -h
figlet: invalid option -- 'h'
Usage: figlet [ -cklnoprstvxDELNRSWX ] [ -d fontdirectory ]
[ -f fontfile ] [ -m smushmode ] [ -w outputwidth ]
[ -C controlfile ] [ -I infocode ] [ message ]
$ pyfiglet -h
Usage: pyfiglet [options] [text..]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-f FONT, --font=FONT font to render with (default: standard)
-D DIRECTION, --direction=DIRECTION
set direction text will be formatted in (default:
auto)
-j SIDE, --justify=SIDE
set justification, defaults to print direction
-w COLS, --width=COLS
set terminal width for wrapping/justification
(default: 80)
-r, --reverse shows mirror image of output text
-F, --flip flips rendered output text over
-l, --list_fonts show installed fonts list
-i, --info_font show font's information, use with -f FONT
Well, I cant say its fully ported in terms of options, but I would say they are close, the CLI isnt the point here, but the programmical interface is, that you can just get a FIGlet-style output right in your Python script. I always shake my head whenever I see someone coding something like the following:
os.system('clear')
os.system('tput cup 0 0')
Why do I dislike code above? Just think about should you do in that way, you would understand why usually think this isnt a good idea.
With pyfiglet, you dont need to pipe in FIGlet if you really want those big text with fancy fonts. You just import the library and generate like, from README:
>>> from pyfiglet import Figlet
>>> f = Figlet(font='slant')
>>> print f.renderText('text to render')
__ __ __ __
/ /____ _ __/ /_ / /_____ ________ ____ ____/ /__ _____
/ __/ _ \| |/_/ __/ / __/ __ \ / ___/ _ \/ __ \/ __ / _ \/ ___/
/ /_/ __/> </ /_ / /_/ /_/ / / / / __/ / / / /_/ / __/ /
\__/\___/_/|_|\__/ \__/\____/ /_/ \___/_/ /_/\__,_/\___/_/
It supports many fonts, maybe even all of FIGlet fonts, run pyfiglet -l to get the list.
pyfiglet is made by Christopher Jones, Stefano Rivera, and Peter Waller, under the GPLv2. It first appeared in 2007, now the version 0.7 (2014-06-08), works for both Python 2 and 3.